package cn.itcast.oa.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import cn.itcast.oa.base.BaseDAOimpl;
import cn.itcast.oa.model.Privilege;
import cn.itcast.oa.service.PrivilegeService;

@Service
@SuppressWarnings("unchecked")
public class PrivilegeServiceImpl extends BaseDAOimpl<Privilege> implements PrivilegeService {

	
	@Override
	public List<Privilege> findTopList() {
		
		return getSession().createQuery(	
				"FROM Privilege p WHERE p.parent IS NULL ORDER BY p.id ASC" 
				).list();
	}

	@Override
	public List<String> findAllPrivilegeUrl() {
		return getSession().createQuery(
				"SELECT DISTINCT p.url FROM Privilege p WHERE p.url IS NOT NULL ORDER BY p.id ASC").list();
	}

}
